package org.edu.modules.logistics.bx.service.impl;

import org.apache.shiro.SecurityUtils;
import org.edu.common.base.BasePageDto;
import org.edu.common.base.BaseServiceImpl;
import org.edu.common.system.vo.LoginUser;
import org.edu.common.utils.ConvertUtils;
import org.edu.common.base.BaseServiceImpl;
import org.edu.modules.logistics.bx.mapper.VeHqBaoxiuMapper;
import org.edu.modules.logistics.bx.entity.VeHqBaoxiu;
import org.edu.modules.logistics.bx.dto.VeHqBaoxiuDto;
import org.edu.modules.logistics.bx.service.VeHqBaoxiuService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import java.util.Date;


/**
 * 实现类
 */
@Service
public class VeHqBaoxiuServiceImpl extends BaseServiceImpl<VeHqBaoxiu, VeHqBaoxiuMapper> implements VeHqBaoxiuService {

    public IPage<VeHqBaoxiuDto> pageDto(BasePageDto page, @Param(Constants.WRAPPER) Wrapper queryWrapper){
        return mapper.pageDto(page,queryWrapper);
    }
    /**
    * 查询实体类
    */
    public VeHqBaoxiuDto findDtoById(String id) {
        VeHqBaoxiu entity = super.findById(id);
        VeHqBaoxiuDto dto = ConvertUtils.convertToDto(entity, VeHqBaoxiuDto.class);
        return dto;
    }

    /**
    * 新增或者修改
    */
    public void insertOrUpdate(VeHqBaoxiuDto dto,Boolean isAdd){
        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
        dto.setApplyUser(sysUser.getId());
        dto.setApplyUserName(sysUser.getRealname());
        if(isAdd){
            super.insert(dto);
        }else{
            super.update(dto);
        }
    }

}
